#ifndef DECOMPRESS
#define DECOMPRESS

#include <cmath>
#include <iostream>
#include "compressData.h"
#include "Image.h"
#include "waveletTransform.h"
#include "binFile.h"
#include <map>

class Decompress
{    double **tmp;
    double **tmp2;
private:
    WaveletTransform *wav;

    int q;

public:
    Decompress(WaveletTransform *w):wav(w),q(1){}

    Decompress(WaveletTransform *w,int x):wav(w),q(x){}

    ~Decompress()
    {
        delete  wav;
    }

    void setQuantize(int x)
    {
        q=x;
    }

    void quantize(double **tab, int width, int height,int w)
    {
        for(int i=0; i<height; ++i)
        {
            for(int j=0; j<width; ++j)
            {
	      //if(j>width/2)
	      //{
                tab[i][j]=tab[i][j]*q*w;
	      //}
	      //tab[i][j]=tab[i][j]*q*2;
	    }
        }
    }

    DecompressData* startDecompress(DecompressData *data, int width, int height)
    {
        std::cout<<"start decompress"<<std::endl;

        DecompressData* data2=new DecompressData(width,height);
	
	double** y=data->getY();
	
        quantize(y,width,height,1);
        data2->setY(wav->reverseTransform(y, width, height));
	
	double** cb=data->getCb();
        quantize(cb,width,height,2.5);
        data2->setCb(wav->reverseTransform(cb, width, height));

	
	double** cr=data->getCr();
        quantize(cr,width,height,2.5);
        data2->setCr(wav->reverseTransform(cr, width, height));
	
	/*for(int i=0; i<height; ++i)
        {
            delete [] y[i];
            delete [] cb[i];
            delete [] cr[i];
        }

        delete[] y;
        delete[] cb;
        delete[] cr;*/
    

        return data2;
    }
}; 


#endif
